<template>
  <section 
    :class="['tab', {'badge': props.badgeText}, {'active': props.isActive}]"
    :style="`--badgeText: '${props.badgeText}'`"
  >
    <div class="content">
      <slot></slot>
    </div>
  </section>
</template>

<script lang="ts" setup>
import { ref, computed, onMounted, PropType } from 'vue';

const props = defineProps({
  /** 徽标文字内容 */
  badgeText: {
    type: String as PropType<string | number>,
    default: '',
  },
  /** 是否激活 */
  isActive: {
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits<{
  (e: 'update:show', show: boolean): void
  (e: 'submit'): void
}>();

onMounted(()=>{

})

defineExpose({
  
})
</script>

<style lang="scss" scoped>
.tab {
  position: relative;
  box-sizing: border-box;
  color: #0d6895;
  cursor: pointer;
  // 激活时
  &.active {
    // 线
    &::before {
      content: "";
      position: absolute;
      width: 90%;
      height: 3px;
      left: 5%;
      bottom: 0;
      background-color: #0d6895;
      border-radius: 0 0 4px 4px;
    }
    .content {
      
    }
  }
  // 徽标
  &.badge .content::after {
    content: var(--badgeText);
    position: relative;
    display: inline-block;
    top: -0.7em;
    color: rgb(43, 34, 51);
    font-size: 12px;
    background-color: rgb(240, 236, 243);
    border-radius: 6px;
    padding: 0 4px;
  }
  .content {
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    text-wrap: nowrap;
    // hover时内容区样式
    &:hover {
      background-color: rgba(33, 126, 172, .2);
    }
  }
}
</style>
